{* $Id$ *}
{include_core file="admin/lib/header.html" title="影院详情"}
  <div class="page-header border-bottom clearfix">
    <h2 class="left">影院详情</h2>
    <a href="{AnUrl("cinema/admin/cinema_manage")}" class="btn btn-default btn-sm right">&lt; 返回影院列表</a>
    <a href="{AnUrl("cinema/admin/cinema_manage/edit?id=$id")}" class="btn btn-default btn-success btn-sm right">编辑</a>
  </div>

  <!--start:列表-->
  <table class="list-table">
    <thead>
      <tr>
        <th colspan="4">影院信息</th>
      </tr>
    </thead>
    <tbody>
    <tr>
        <td width="25%" style="font-weight:bold">影院名称</td>
        <td width="25%">{if $zzb_info.cinema_name}{$zzb_info.cinema_name}{else}{$store_info.title}{/if}</td>
        <td width="25%" style="font-weight:bold">专资办编码</td>
        <td width="25%">{$store_info.zzb_id}</td>
    </tr>
      <tr>
        <td style="font-weight:bold">影院负责人</td>
        <td>{$store_info.owner_name}</td>
          <td style="font-weight:bold">影院负责人电话</td>
          <td>{$store_info['mobile']}</td>
      </tr>
      <tr>
        <td style="font-weight:bold">影院排名</td>
        <td>{$zzb_info.ranking}</td>
          <td style="font-weight:bold">银幕数</td>
          <td>{$zzb_info['screen_count']}</td>
      </tr>
    <tr>
        <td style="font-weight:bold">所属院线</td>
        <td>{$zzb_info.circuit}</td>
          <td style="font-weight:bold">所属影投公司</td>
          <td>{$zzb_info['investment_company']}</td>
      </tr>
    <tr>
        <td style="font-weight:bold">所在地</td>
        <td>{if $zzb_info.province}
            {$zzb_info.province}-{$zzb_info.city}-{$zzb_info.county}
            {else}
            {$store_info['address']}
            {/if}
        </td>
          <td style="font-weight:bold">开店时间</td>
          <td>{$zzb_info['open_at']}</td>
      </tr>
    </tbody>
      </table>
<br>
    <table class="list-table">
        <thead>
        <tr>
            <th colspan="4">公司信息</th>
        </tr>
        </thead>
      {* <tr>
        <td style="font-weight:bold">营业执照</td>
        <td>{if $user_store_info['cert_company']}<a href="{_image($user_store_info['cert_company'])}" target="_blank"><img alt="营业执照" src="{_image($user_store_info['cert_company'], 'store-small')}"></a>{else}暂无营业执照{/if}</td>
        <td style="font-weight:bold">身份证</td>
        <td>{if $user_store_info['cert_idcard_front']}<a href="{_image($user_store_info['cert_idcard_front'])}" target="_blank"><img alt="身份证正面照" src="{_image($user_store_info['cert_idcard_front'], 'store-small')}"></a>{else}暂无身份证正面照{/if}&nbsp;&nbsp;&nbsp;&nbsp;{if $user_store_info['cert_idcard_back']}<a href="{_image($user_store_info['cert_idcard_back'])}" target="_blank"><img alt="身份证背面照" src="{_image($user_store_info['cert_idcard_back'], 'store-small')}"></a>{else}暂无身份证背面照{/if}</td>
      </tr> *}
      <tr>
        <td  style="font-weight:bold">所属合伙人</td>
        <td>{$store_info['agency_info']['realname']}</td>
        <td  style="font-weight:bold">所属合伙人手机号</td>
        <td>{$store_info['agency_info']['mobile']}</td>
      </tr>
      <tr>
        <td  style="font-weight:bold">所属院线账号</td>
        <td>{$store_info['cinema_manager_info']['realname']}</td>
        <td  style="font-weight:bold">所属院线账号手机</td>
        <td>{$store_info['cinema_manager_info']['mobile']}</td>
      </tr>
      <tr>
        <td style="font-weight:bold">签约时间</td>
        <td>{$store_info['sign_time']}</td>
        <td style="font-weight:bold">影院类型</td>
        <td>{$store_info['store_type']}</td>
      </tr>
        <tr>
            <td style="font-weight:bold">是否允许赊账</td>
            <td colspan="3">{if $store_info['is_allow_credit']}允许{else}不允许{/if}</td>
        </tr>
      <tr>
        <td style="font-weight:bold">积分</td>
        <td>{$store_info.score}</td>
        <td style="font-weight:bold">影院等级</td>
        <td>{$level}</td>
      </tr>
      <tr>
        <td style="font-weight:bold">影院地址</td>
        <td>{$store_info['address']}</td>
        <td style="font-weight:bold">地址坐标</td>
        <td>经度:{$store_info.longitude}<br/>纬度:{$store_info.latitude}</td>
      </tr>
      <tr>
          <td style="font-weight:bold">影院状态</td>
          <td>{store_config::$status_arr[$store_info['status']]}</td>
          <td style="font-weight:bold"></td>
          <td></td>
      </tr>
      <tr>
        <td style="font-weight:bold">门头图</td>
        <td colspan="3">{if $store_info['cover']}<a href="{if $store_info.cover}{_image($store_info.cover)}{else}{store_helper::cover($store_info.cover)}{/if}" target="_blank"><img style="width: 200px" src="{if $store_info.cover}{_image($store_info.cover)}{else}{store_helper::cover($store_info.cover)}{/if}"></a>{else}暂无门头图{/if}</td>
      </tr>
    </tbody>
  </table>
<br>
  <table class="list-table">
    <!-- <caption>按状态：
      <a href='{AnUrl("store/admin?status=1")}' {if $status == 1} class="label label-primary" {else} class="label label-default" {/if}>正常</a>
      <a href='{AnUrl("store/admin?status=0")}' {if $status == 0} class="label label-primary" {else} class="label label-default" {/if}>已禁用</a>
    </caption> -->
    <thead><tr>
      <th colspan="2">设备绑定信息</th>
    </tr></thead>
    <tbody>
    <tr>
        <td style="min-width:60px;font-weight:bold"">设备类型</td>
        <td style="min-width:60px;font-weight:bold"">设备序列号</td>
    </tr>
      {foreach $store_info['store_device_list'] as $k=>$v}
        {foreach $v['device_list'] as $key=>$val}
        <tr {if $key%2 == 1} class="bg-gray"{/if}">
          <td>{$v.res_name_str}</td>
          <td>{$val.device_no}</td>
        </tr>
        {/foreach}
      {foreachelse}
          <tr><td class="txtleft" colspan="2">暂无数据</td></tr>
      {/foreach}
    </tbody>
    {if $status == 1}
    <tfoot><tr><td><input type="checkbox" class="selectAll"></td><td colspan="6"><a href="{AnUrl("store/admin/delete")}" class="btn btn-danger btn-xs deleteAll">批量禁用</a></td></tr></tfoot>
    {/if}
  </table>
<br>
<table class="list-table">
    <tbody>
    <tr>
        <td style="width:20%;font-weight:bold;font-size: 28px;">总进货金额</td>
        <td><span class="label label-info" style="font-size: 28px;">¥ {$all_order_money}</span></td>
    </tr>
    <tr>
        <td id="chart_container" style="height:400px;" colspan="2"></td>
    </tr>
    </tbody>
</table>
<div style="height: 10px;"></div>
{include_core file="admin/lib/pager.html"}
<table class="list-table goods-table">
    {$order_type_list = order_config::$order_type}
    <thead>
    <tr>
        <th style="min-width:100px;">订单编号</th>
        <th style="width:1em">&nbsp;</th>
        <th style="min-width:200px;">商品</th>
        <th style="width:30px;">单价(元)</th>
        <th style="width:30px;">数量</th>
        <th style="width:30px;">单项总价(元)</th>
        <th style="width:30px;">总量</th>
        <th style="min-width:100px;text-align:right">价格汇总(元)</th>
        <th style="min-width:150px;">支付时间</th>
        <th style="width:50px;">状态</th>
    </tr>
    </thead>
    <tbody>
    {foreach $order_list as $k => $v}
    <tr><td colspan="11" class="hr">&nbsp;</td></tr>
    {if $v.order_relation_count}
    {foreach $v.order_relation as $key=>$order_relation_info}
    <tr data-id="{$v.id}" id="dataList{$v.id}">
        {if $key == 0}
        <td rowspan="{$v.order_relation_count + $v.order_exchange_relation_count}">
            {if $v.is_ious == 1}<span class="label label-success">白</span>{/if}
            {if $v.pay_user_money > 0}<span class="label label-info">余</span>{/if}
            {if $v.exchange_num > 0}<span class="label label-warning">兑</span>{/if}
            {if $v.original_agency_id > 0}<span class="label label-danger">派</span>{/if}
            {if $v.is_ious || $v.pay_user_money > 0 || $v.exchange_num > 0 || $v.original_agency_id > 0}<br />{/if}
            订单号：<br />
            {order_helper::order_id_encode($v.id)}<br />
            下单时间：<br />{$v.add_time}<br />
            {if $v.task_user_id}代理下单：{user_helper::display_name($v.task_user_id)}<br />{/if}
            {if $v.task_desc}代理备注：{$v.task_desc}<br />{/if}
            {if $v.transaction_id}
            交易号:<br />{$v.transaction_id}
            {/if}
        </td>
        {/if}
        {if $key == 0}
        <td class="abs-center" style="color:#bbbbbb;font-size:14px;font-weight:bold;background-color:#f8f8f8;" rowspan="{$v.order_relation_count}"> 现 付</td>
        {/if}
        {$goods_info = goods_helper::get_goods_info($order_relation_info['goods_id'])}
        <td>
            <span class="label label-default">{$goods_info['title']}</span><br/>
            分类：{_uri('category', $goods_info['category_id'], 'title')}<br/>
            商品简介：<br/><p class="">{$goods_info['intro']}</p>
        </td>
        <td><span class="label label-default">{num_keep_two_round($order_relation_info.goods_price)}</span></td>
        <td>{$order_relation_info.goods_num}</td>
        <td><span class="label label-default">{num_keep_two_round($order_relation_info.real_price)}</span></td>
        {if $key == 0}
        <td rowspan="{$v.order_relation_count + $v.order_exchange_relation_count}">{$v.goods_num}</td>
        <td rowspan="{$v.order_relation_count}" style="text-align:right;">
            <p>
                <span class="label label-default">总价 {num_keep_two_round($v.price)}</span><br />
                {if $v.pay_user_money > 0}
                <span class="label label-warning">余额支付 {num_keep_two_round($v.pay_user_money)}</span><br />
                {/if}
                <span class="hr"></span>
                <span class="label label-info">需付 {num_keep_two_round($v.price - $v.pay_user_money)}</span><br />
            </p>
            {if $v.is_ious}
            <p>
                <span class="label label-{if $v.order_delivery_note.is_return_cash}success">已{else}default">将{/if}返本金 {num_keep_two_round($v.order_delivery_note.return_cash)}</span><br />
                <span class="label label-{if $v.order_delivery_note.is_return_bbcoin}success">已{else}default">将{/if}返抱币 {intval($v.order_delivery_note.return_bbcoin)}</span><br />
            </p>
            {/if}
        </td>
        <td rowspan="{$v.order_relation_count + $v.order_exchange_relation_count}">
            {if $v.pay_time != '0000-00-00 00:00:00'}
            <p>{$v.pay_time}</p>
            {else}
            <p>未支付</p>
            {/if}
        </td>
        {$order_progress_list = order_config::$store_progress}
        <td rowspan="{$v.order_relation_count + $v.order_exchange_relation_count}">
            {if $v.progress == 1}
            <span class="label label-warning">{$order_progress_list[$v.progress]}</span>
            {elseif $v.progress == 10}
            <span class="label label-success">{$order_progress_list[$v.progress]}</span>
            {elseif $v.progress == 15}
            <span class="label label-default">{$order_progress_list[$v.progress]}</span>
            {else}
            <span class="label label-info">{$order_progress_list[$v.progress]}</span>
            {/if}
            <!-- 送货单状态 -->
            {$delivery_status = $v.order_delivery_note.status}
            {if isset($delivery_status)}
            <span{if $delivery_status != 0} style="display:none"{/if} class="label label-default js-delivery-status js-delivery-status-0">{order_config::$delivery_status[0]}</span>
            <span{if $delivery_status != 1} style="display:none"{/if} class="label label-warning js-delivery-status js-delivery-status-1">{order_config::$delivery_status[1]}</span>
            <span{if $delivery_status != 2} style="display:none"{/if} class="label label-info js-delivery-status js-delivery-status-2">{order_config::$delivery_status[2]}</span>
            <span{if $delivery_status != 3} style="display:none"{/if} class="label label-danger js-delivery-status js-delivery-status-3">{order_config::$delivery_status[3]}</span>
            <span{if $delivery_status != 4} style="display:none"{/if} class="label label-success js-delivery-status js-delivery-status-4">{order_config::$delivery_status[4]}</span>
            <span{if $delivery_status != 5} style="display:none"{/if} class="label label-warning js-delivery-status js-delivery-status-5">{order_config::$delivery_status[5]}</span>
            {/if}
            <!-- /送货单状态 -->
        </td>
        {/if}
    </tr>
    {/foreach}
    {/if}
    {if $v.order_exchange_relation_count}
    {foreach $v.order_exchange_relation as $key => $order_exchange_relation_info}
    {$goods_info = goods_helper::get_goods_info($order_exchange_relation_info['goods_id'])}
    <tr style="background-color:#fffeec">
        {if $key == 0}
        <td class="abs-center" style="color:#b7ab40;font-size:14px;font-weight:bold;background-color:#fffdbf;" rowspan="{$v.order_exchange_relation_count}"> 兑 换</td>
        {/if}
        <td style="overflow:hidden;">
            <span class="label label-warning">{$goods_info['title']}</span><br/>
            分类：{_uri('category', $goods_info['category_id'], 'title')}<br/>
            商品简介：<br/><p class="">{$goods_info['intro']}</p>
        </td>
        <td><span class="label label-warning">{intval($order_exchange_relation_info.goods_price)} 币</span></td>
        <td>{$order_exchange_relation_info.goods_num}</td>
        <td><span class="label label-warning">{intval($order_exchange_relation_info.real_price)} 币</span></td>
        {if $key == 0}
        <td rowspan="{$v.order_exchange_relation_count}" style="text-align:right;">
            <span class="label label-warning">抱币总计 {intval($v.pay_bbcoin)}</span>
        </td>
        {/if}
    </tr>
    {/foreach}
    {/if}
    {foreachelse}
    <tr><td class="txtleft" colspan="10">暂无数据</td></tr>
    {/foreach}
    </tbody>
</table>

{load_js file='echarts/echarts.min.js'}
<script type="text/javascript">
    var xAxisData = [{join(',', $recent_half_year_date_list)}];
    var seriesData = [{join(',', $recent_half_year_money_list)}];
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('chart_container'));

    // 指定图表的配置项和数据
    var option = {
        title: {
            text: '近半年影院进货金额'
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data:['月进货金额']
        },
        toolbox: {
            feature: {
                saveAsImage: {}
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: xAxisData
        },
        yAxis: {
            type: 'value'
        },
        series: [{
            name:'月进货金额',
            type:'line',
            stack: '总计',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            data:seriesData
        }]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
</script>
<script type="text/javascript">
$(function(){
  /* // 声明一个字段映射
  var field_mapping = new Array();
   field_mapping['id'] = '店铺id';
   field_mapping['user_name'] = '分店店长';
   field_mapping['owner_name'] = '总店店长';
   /* field_mapping['agency_name'] = '经销商';
   field_mapping['marketing_name'] = '市场人员'; */
   /* field_mapping['type'] = '影院类型';
   field_mapping['store_title'] = '影院名称';
   field_mapping['cover'] = '门头图';
   field_mapping['store_order'] = '分店序号';
   field_mapping['address'] = '影院地址';
   field_mapping['score'] = '影院积分';
   field_mapping['level'] = '影院等级';
   field_mapping['sign_user_name'] = '签约人员';
   field_mapping['sign_user_mobile'] = '签约人员的手机号';
   field_mapping['sign_time'] = '签约时间'; */

   // 设备状态
   var device_status_arr = new Array();
   device_status_arr[0] = '出厂';
   device_status_arr[1] = '损坏';
   device_status_arr[2] = '正常';
   device_status_arr[3] = '停用';
   device_status_arr[404] = '暂无';

// 将指定的元素设置为可视区域居中
  function center_format(obj){
      // 获取可是窗口的宽度
      var winWidth  = $(window).width();
      var winHeight = $(window).height();

      // 计算窗体本身的宽和高
      var objWidth = obj.width();
      var objHeight = obj.height();

      // 设置窗体的位置
      obj.css('position', 'fixed');
      // 计算left和top值
      var objLeft = (winWidth - objWidth)/2;
      var objTop = (winHeight - objHeight)/2; // 如果除以2感觉不是垂直居中
      obj.css('left', objLeft+'px');
      obj.css('top', objTop+'px');

  }

// 高级搜索
$('.js_advanced').click(function(e){
  e.preventDefault();
  var thisObj = $(this);
  var outBox  = thisObj.closest('form');
  if (thisObj.hasClass('js_isOpen')) {
    thisObj.removeClass('js_isOpen open');
    outBox.find('input').show();
    outBox.find('button').show();
    $('.js_advancedForm').hide();
  } else {
    thisObj.addClass('js_isOpen open');
    outBox.find('input').hide();
    outBox.find('button').hide();
    $('.js_advancedForm').show();
  }
});

var is_show_confirm = false;
// 查看影院信息
$('.js_verifyStore').click(function(){
    if (is_show_confirm) {
        return false;
    }
    // 获取此影院的id
    var url = $(this).attr('url');
    var th = $(this);

    $('.float-bg').show();
    var list = $('.js_secondDealerList').clone(true, true);

    list.find('.js_verifySuccess').attr('href', '{AnUrl("store/admin/recover_store")}');
    list.find('.js_hiddenStoreId').val('{$store_info.id}');
    $('body').append(list);

    // 设置弹窗的位置
    center_format(list);
    list.show();
    is_show_confirm = true;
    list.find('.js_closeDealerList').click(function(){
        list.hide();
        list.remove();
        $('.float-bg').hide();
        is_show_confirm = false;
    });

    $('.js_verifySuccess').click(function(){
        showMask('正在提交中...', 1);
        var extra = list.find('textarea[name=extra]').val();
        var targetUrl= "{AnUrl("store/admin/recover_store?id={$store_info.id}")}"+"&extra="+extra+'store_type={$store_type}';
        $(this).attr('href', targetUrl);
        is_show_confirm = false;
    });

    return false;
});

// 单个禁用
$(".js_deleteStore").click(function(){
    var selectId = {$store_info.id};
    if (!selectId) {
      alert('请选择要操作记录');
    }
    var clickObj = $(this);
    var url = clickObj.attr("url");
    var cardListBox = clickObj.closest('.cardListBox');
    showConfirm('确定要删除这家店铺吗？', 1, function(){
      $.post(url, { 'id':selectId }, function(json){
        if (json.info != 'ok') {
          alert(json.info);
        } else {
          showMsg('删除成功!被删除影院可在回收站还原.', 1);
          location.href = '{AnUrl("store/admin")}';
        }
      }, 'json');
    });
    return false;
  });
});
</script>
<div class="float-confirm js_secondDealerList" style="z-index: 20000;display: none; width:auto; height:auto; margin:0px; position : fixed;">
  <div class="float-confirm-con" style="margin:0px 0px;">
    <a class="icon-close js_closeDealerList" href="javascript:void(0);">关闭</a>
    <p style="font-size:18px;color:#23a18b;" class="js_dealerTitle">备注:</p>
    <div style="width:500px;max-height:400px;over-flow:hidden;margin-bottom:15px;">
      <form action="{AnUrl("store/admin/recover_store")}" method="get">
      
      <table style="line-height:50px;width:100%;line-height:24px;margin:0 auto; padding-left:20px;" class="js_refundTable">
        <tr>
          <td>
            <input type="hidden" name="id" value="{$store_info['id']}" class="js_hiddenStoreId" />
            <textarea name="extra" class="add-f-area textarea_box"></textarea>
          </td>
        </tr>
        <tr>
          <td style="text-align:center;padding:10px;" ><a href="javascript:;" class="btn btn-success right js_verifySuccess" ><i class="icon-trash icon-white"></i>确认通过</a></td>
        </tr>
      </table>
      </form>
    </div>
  </div>
</div>
<!-- <div class="float-bg" style="z-index: 19999; display: none"></div> -->
{include_core file="admin/lib/pager.html"}
<!--end:列表-->
{load_js file='zclip/jquery.zclip.min.js'}
{load_js file='zclip/ZeroClipboard.js'}
{include_core file="admin/lib/footer.html"}